﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BbsbWebService.Classes;
using BbsbWebService.Enums;
using System.ServiceModel;
using BbsbWebService.Service;
using System.ServiceModel.Web;
using System.ServiceModel.Description;

namespace BbsbWebService.Repositories.Client
{
    public class ClientItemRepository : ClientPowerRepositoryBase<ControllableItem>
    {
       public override void Initialise()
        {
            var items = ClientCommon.Service.GetAllItems();
            foreach (var item in items)
            {
                Items.Add(item);
            }
            ClientCommon.Initialise();
        }

        public override void SaveItem(ControllableItem item)
        {
            ClientCommon.Service.SaveItem(item);
        }

        public override void RemoveItem(ControllableItem item)
        {
            ClientCommon.Service.RemoveItem(item);
        }

        public override PowerState Toggle(Guid id)
        {
            return ClientCommon.Service.Toggle(id);
        }

        protected override PowerState SendPowerBase(CommandItem item, PowerOption option)
        {
            return ClientCommon.Service.SendPower(item.Id, option);
        }

        public override void Refresh()
        {
            Items.Clear();
            Initialise();
        }

        public override System.Xml.Linq.XElement SaveRepository()
        {
            // Do Nothing in the client...
            return null;
        }
    }
}
